package com.crazy.email;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.mail.javamail.JavaMailSender;
import org.springframework.mail.javamail.JavaMailSenderImpl;

@Configuration
public class EmailConfiguration {

	/**
     * smtp服务器
     */
    @Value("${email.hostname}")
    private String hostName;

    /**
     * 邮箱账号
     */
    @Value("${email.username}")
    private String userName;

    /**
     * 邮箱密码
     */
    @Value("${email.password}")
    private String password;

    @Bean
    public JavaMailSender javaMailSender() {
        JavaMailSenderImpl sender = new JavaMailSenderImpl();
        sender.setHost(hostName);
        sender.setUsername(userName);
        sender.setPassword(password);
        return sender;
    }
}
